package com.catchu.pattern.creational.迭代器模式.a入门.aggregate;

/**
 * 具体的聚合对象,就是构建一个数组或集合对象
 */
public class ConcreteAggregate extends Aggregate {

    /**
     * 构建一个数组类型的聚合对象
     */
    private String[] ss = null;

    public ConcreteAggregate(String[] ss) {
        this.ss = ss;
    }

    public Object get(int index){
        Object result = null;
        if(index <= ss.length){
            result = ss[index];
        }
        return result;
    }

    /**
     * 获取索引的大小
     * @return
     */
    public int size(){
        return ss.length;
    }
}
